﻿using System;
using Guru.Web.UI;

public partial class UserControl_CustomerFiltering : GuruUserControl
{
    public enum FilteringMode
    {
        Quick,
        Advance
    }

    #region Properties
    public FilteringMode FilterMode
    {
        set
        {
            ViewState["FilterMode"] = value;
        }
        get
        {
            if (ViewState["FilterMode"] == null) return FilteringMode.Quick;
            else return (FilteringMode)Enum.Parse(typeof(FilteringMode), ViewState["FilterMode"].ToString());
        }
    }
    public string GuestName
    {
        get
        {
            if (FilterMode == FilteringMode.Quick)
                return string.Empty;
            else
                return this.uxGuestName.Text.Trim();
        }
        set
        {
            this.uxGuestName.Text = value;
        }
    }
    public string Phone
    {
        get
        {
            if (FilterMode == FilteringMode.Quick)
                return string.Empty;
            else
                return this.uxPhone.Text.Trim();
        }
        set
        {
            this.uxPhone.Text = value;
        }
    }
    public string IdNumber
    {
        get
        {
            if (FilterMode == FilteringMode.Quick)
                return string.Empty;
            else
                return this.uxIdNumber.Text.Trim();
        }
        set
        {
            this.uxIdNumber.Text = value;
        }
    }
    public string VisaPasswort
    {
        get
        {
            if (FilterMode == FilteringMode.Quick)
                return string.Empty;
            else
                return this.uxVisaPasswort.Text.Trim();
        }
        set
        {
            this.uxVisaPasswort.Text = value;
        }
    }
    public string Address
    {
        get
        {
            if (FilterMode == FilteringMode.Quick)
                return string.Empty;
            else
                return this.uxAddress.Text.Trim();
        }
        set
        {
            this.uxAddress.Text = value;
        }
    }
    public string Email
    {
        get
        {
            if (FilterMode == FilteringMode.Quick)
                return string.Empty;
            else
                return this.uxEmail.Text.Trim();
        }
        set
        {
            this.uxEmail.Text = value;
        }
    }
    public string Keywords
    {
        get
        {
            if (FilterMode == FilteringMode.Advance)
                return string.Empty;
            else
                return this.uxKeywords.Text.Trim();
        }
        set
        {
            this.uxKeywords.Text = value;
        }
    }
    public event EventHandler Searched;
    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (!string.IsNullOrEmpty(HSMSessionManager.CurrentGuestFiltering))
            {
                this.uxKeywords.Text = HSMSessionManager.CurrentGuestFiltering;
                HSMSessionManager.CurrentGuestFiltering = string.Empty;
            }
        }
    }
    protected void uxSwitchToAdvance_Click(object sender, EventArgs e)
    {
        this.FilterMode = FilteringMode.Advance;
        this.uxContainerAdvance.IsExpanded = true;
        this.uxContainerAdvance.Visible = true;
        this.uxContainerStandard.Visible = false;
    }
    protected void DoSearchClick(object sender, EventArgs e)
    {
        if (Searched != null)
        {
            this.Searched(this, e);
        }
    }
   
}
